<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title>医疗机构列表</title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>医疗机构列表</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">交易</a></li>
            <li class="active"><a href="#">医疗机构列表</a></li>
        </ol>
    </section>
    <section class="content">
      <form id="form" method="post" class="form-horizontal">
        <div class=" box box-success">
            <div class="box-body">
               <div class="input" style="margin-top:-5px" >
                    <div class="textalign1">医疗机构名称：</div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="shospName" placeholder="医疗机构名称"/>
                    </div>
                    <!-- <div class="textalign">医疗机构编码：</div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="hospCode" placeholder="医疗机构编码"/>
                    </div> -->
                    <%-- <div class="textalign"><spring:message code="message.listForm.yiLiaoJiGouFenLei"/>：</div>
                    <div class="boxinput">
                        <select class="textinput"  id="shospCl" >
                            <option selected="selected" value="">请选择</option>
                             <c:forEach items="${clList}" var="cl">
                                <option  value="${cl.dicCode}">${cl.dicName}</option>
                            </c:forEach>
                        </select>
                    </div> --%>
                    <div class="textalign">是否零差率医院：</div>
	                    <div class="boxinput">
                        <select class="textinput" id="hospClassifyIds" name="hospClassifyIds">
                        	<option value="">请选择</option>
                            <option value="2">是</option>
                            <option value="1">否</option>
                        </select>
                    	</div>
                    <div class="textalign">医疗机构地区：</div>
                    <div class="boxinput">
                       <table style="width:100%;">
                           <tr>
                              <td style="width:33%">
                                <select class="textinput" id="sysAreaId" name="sysAreaId" disabled="disabled">
                                    <option value="${area.areaId}">${area.areaName}</option>
                                </select>
                              </td>
                              <td style="width:33%">   
                                <select class="textinput"  id="area1Id"></select>
                                </td>
                              <td style="width:33%">
                                <select class="textinput"  id="area2Id"></select>
                              </td>
                           </tr> 
                        </table>     
                    </div>
               </div>
               <div class="input" style="margin-top:3px">
                    <div class="textalign1"><spring:message code="message.lable.yiLiaoJiGouDengJi"/>：</div>
		                    <div class="boxinput">
		                         <select class="textinput"  id="hospType"  name="hospType"></select>
		                    </div>  
                    <div class="textalign" >
                        <button type="button" class="btn btn-success btn-sm" onclick="search()" id="selectSee">查&nbsp;询</button>
                    </div> 
               </div>
            </div>
          </div>
        </form>
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">


    function search(page) {
        var shospName = $("#shospName").val();
        var shospCl = $("#shospCl").val();
        var hospCode = $("#hospCode").val();
        var hospClassifyIds = $("#hospClassifyIds").val();
        var hospType = $("#hospType").val();
        var areaId = $("#area2Id").val();
        if (areaId == null || areaId == "") {
        	areaId = $("#area1Id").val();
        }
        if (areaId == null || areaId == "") {
            areaId = $("#sysAreaId").val();
        }
        $("#gridlist").jqGrid("clearGridData");
            $("#gridlist").jqGrid('setGridParam',{  
            mtype: "POST",
            datatype:'json',
            postData:{"hospName":shospName, "hospClassify":shospCl,"hospClassifyIds":hospClassifyIds,"hospType":hospType, "hospCode":hospCode,"areaId":areaId},
            page : (page || 1)
        }).trigger("reloadGrid"); //重新载入  
    }

        $(function () {	
        	//绑定回车 
            $('#shospName,#hospClassify,#hospClassifyIds,#hospType,#hospCode,#sysAreaId,#area1Id,#area2Id').bind('keydown', function(event) {
               if (event.keyCode == "13") {
                   $('#selectSee').click();
               }
           }); 
        	
           $("#shospName").focus(); //加载页面光标在第一个查询框内
        	
        	
        	
        	
        	
            $("#gridlist").jqGrid({
                url: "getHospListByWSJ.html",
                mtype: "POST",
                postData: { "projId" : ""},
                datatype: "json",
                autowidth: true,
                //height: create(),
                colNames: ['医疗机构ID', '医疗机构编码', '医疗机构名称', '医疗机构地区',
                           /* '<spring:message code="message.listForm.yiLiaoJiGouFenLei"/>',  */
                           '是否零差率医院',
                           '<spring:message code="message.listForm.yiLiaoJiGouLeiXing"/>',
                           '医疗机构等级', '组织机构代码'],
                colModel: [
                    { name: 'hospId', width: 80 , align:"center" ,sortable: false, hidden:true},
                    { name: 'hospCode', width: 60 , align:"center",sortable: false},
                    { name: 'hospName', width: 60 , align:"left" ,sortable: false/* ,
                        formatter:function(cellvalue, options, row){
                            return "<a href=\"javascript:showHospInfo('" + row.hospCode + "')\">"+cellvalue+"</a>"

                       } */
                    },
                    { name: 'areaName', width: 60 , align:"center" ,sortable: false},
                    /* { name: 'classifyName', width: 50 , align:"center" ,sortable: false}, */
                    { name: 'classifyName', width: 50 , align:"center" ,sortable: false,
                    	formatter : function(val, opts, rowdata) {
                            var strSta = "";
                            if(rowdata.classifyCode == 1){
                                strSta += "否";
                            }else if(rowdata.classifyCode == 2){
                                strSta += "是";
                            }
                            return strSta;
                        }},
                    { name: 'hospTypeName', width: 40 , align:"center" ,sortable: false},
                    { name: 'hospLevelName', width: 40 , align:"center" ,sortable: false},
                    { name: 'orgCode', width: 50 , align:"center",sortable: false }
                ],
                rowNum: 20,
                rowList: [10, 20, 50, 100],
                rownumbers: true,
                pager: "#gridpage",
                viewrecords: true,
				gridComplete: function(){
             	//序号列宽度自适应（参数为jqgridID）
                autoRNWidth("gridlist");
             	//数据只有一条时默认选中（参数为jqgridID）
                 selectByOneData("gridlist");
		        },
                caption: "医疗机构列表 ",
                jsonReader: {
                    repeatitems: false,
                    id: "drugId"
                }
            });
            
            $("#hospType").HNSelect({ 
                url: "${ctx}/selectController/getDicSys.html", 
                data: { 'ID' : "002" },
                defaultText: "<option value=''><spring:message code="message.select.option"/></option>",
                defaultselect: "",
            });
            
            $("#area1Id").HNSelect({
                url: "${ctx}/selectController/getArea.html", 
                data: { ID: '${sysAreaId}' }, 
                defaultText: "<option value=''>请选择</option>",
                defaultselect: "",
                func: function () {
                    $("#area2Id").HNSelect({
                        parent_selector: "#area1Id", 
                        url: "${ctx}/selectController/getArea.html", 
                        dataid: "ID", 
                        defaultText: "<option value=''>请选择</option>",
                        defaultselect: ""
                    });
                }
            });         
            
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
            $("#gridlist").jqGrid("setGridHeight",create());
			
        });

	
    </script>
</body>
</html>